package com.qf.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qf.pojo.DtsFootprint;
import com.qf.service.footprintService;
import com.qf.util.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;

/**
 * @author Wy
 * @version V1.0
 * @Project MavenDemo
 * @Package com.qf.controller
 * @Description:
 * @Date 2022/7/8 22:16
 */
@RestController
@RequestMapping("/footprint")
@CrossOrigin("*")
public class FootprintController {

      @Autowired
      private footprintService footprintService;

     @RequestMapping("/list")
     public  Object list(String userId, String goodsId,
                         @RequestParam(defaultValue = "1") Integer page,
                         @RequestParam(defaultValue = "10") Integer limit,
                         @RequestParam(defaultValue = "add_time") String sort,
                         @RequestParam(defaultValue = "desc") String order){
          //获取分页集合对象
         IPage<DtsFootprint> list = footprintService.list(userId, goodsId, page, limit, sort, order);
         //获取分页集合对象的个数
         long total = list.getTotal();
         //获取集合对象
         List<DtsFootprint> records = list.getRecords();
         //放入Map集合当中
         HashMap<String,Object> data = new HashMap<>();
           data.put("total", total);
           data.put("items", records);
           //发送
         return ResponseUtil.ok(data);
     }
}
